/* eslint valid-jsdoc: "off" */

'use strict';
const path = require('path');
/**
 * @param {Egg.EggAppInfo} appInfo app info
 */
module.exports = appInfo => {
  /**
   * built-in config
   * @type {Egg.EggAppConfig}
   **/
  const config = exports = {};

  config.cms = {
    host: 'http://localhost:8080',
  };

  config.curl = {
    defContentType: 'application/json; charset=UTF-8', //默认的Content-Type
    defDataType: 'text', // 默认的dataType
    timeout: [10000, 10000] //连接和返回的超时时间
  };

  // use for cookie sign key, should change to your own and keep security
  config.keys = appInfo.name + '_1608383299984_6804';

  config.httpProxy = {
    '/dist': 'http://127.0.0.1:7001'
  };

  // 配置模板引擎
  config.view = {
    defaultViewEngine: 'nunjucks',
    mapping: {
      '.html': 'nunjucks' //左边写成.html后缀，会自动渲染.html文件
    },
  }

  config.security = {
    csrf: {
      ignore: '/api/*/*',
    },
  };

  config.static = {
    prefix: '/public/',
    dir: path.join(appInfo.baseDir, 'app/public'),
    // support lazy load
    dynamic: true,
    preload: false,
    buffer: false,
    maxFiles: 1000,
  };

  /**
   * @see http://mongodb.github.io/node-mongodb-native/2.2/api/Db.html#createCollection
   */
  config.mongoose = {
    // url: process.env.EGG_MONGODB_URL || 'mongodb://139.162.126.86:27111/wpn',
    url: 'mongodb://wx.0heart.cn:52124/wpn',
    options: {
      server: { poolSize: 20 },
      reconnectTries: 10,
      reconnectInterval: 500,
    },
  };


  // add your middleware config here
  config.middleware = [];

  // add your user config here
  const userConfig = {
    // myAppName: 'egg',
  };

  config.miniapp = {
    // secret: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhcHBpZCI6Ind4YzNmYzhjNWY5YTgwODZiMSIsInNlY3JldCI6IjA4ZTEyMGM0OTM0MGFjZDI4OWMyNzQxMzRlYTUyMDYzIiwiaWF0IjoxNjE0Njg2NjQ3fQ.v-9hv6udp36NtPeA-2IwWjwxLduQFSlrnAbG4LONKL8',
  }
  // crypto 数据加密(秘钥随便写，写了最好不要改）
  config.crypto = {
    secret: 'qhdgw@45ncashdaksh2!#@3nxjdas*_672'
  };

  // jwt
  config.jwt = {
    secret: 'qhdgw@45ncashdaksh2!#@3nxjdas*_672'
  };

  return {
    ...config,
    ...userConfig,
  };
};

